<html>
<body>

<b>STOCK REPORT of  <?php echo $_POST["symbol"]; ?></b>
<br /><br />
<?php
include '../utils/stock.php';
require('../utils/fpdf17/fpdf.php');

$stock = new stock;
$stock->get_stock_quote($_POST["symbol"]);
$result = $stock->pe * $stock->pb;
if((!is_numeric($stock->pe) || !is_numeric($stock->pb))){
	$res = "No advise <br>";
}
else if($result<= 22.5) 
	{
		$res = "<font color='green'>PASSED!<br /></font>";
	}
	else 
	{
		$res = "<font color='red'>FAILDED!<br /></font>";
	}

echo "<b>Name: </b>";
echo $stock->name;
echo "<br />";
echo "$res";
echo "<b>Price:</b> ";
echo $stock->last;
echo "<br />";
echo "<b>P/E: </b>";
echo  "".addColor($stock->pe, 15)."";
echo "<br />";
echo "<b>P/B: </b>";
echo  "".addColor($stock->pb, 1.5)."";
echo "<br />";
echo "<b>Dividend/Share: </b>";
echo $stock->div;
echo "<br />";

session_start();
$_SESSION['symbol'] = $stock->symbol;

function addColor($number, $reference){
	if($number <= $reference) 
	{
		$res = "<font color='green'>". $number . "</font>";
	}
	else 
	{
		$res = "<font color='red'>". $number . "</font>";
	}
	
	return $res;
}

?>
<br />
<button type="button" onclick="location.href='createpdf.php'">Export to PDF</button>
<button type="button" onclick="location.href='index.php'">Back</button>






</body>
</html>